package com.gg.user.gguser.controller;


import com.gg.user.gguser.service.GgContractSerice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/contract")
public class GgContractController {

    @Autowired
    private GgContractSerice ggContractSerice;

    /**
     * 增加
     */
    @PostMapping("/addContractItems")
    public Object addContractItems(HttpServletResponse response, HttpServletRequest request, String ggCNumber, String ggCContractName, String ggCInstitutionalName, String ggCTypeOfContract, String ggCcontractAmount, String ggCpersonInCharge, String ggCAuditStatus, String ggCContractTime, String ggCDueTime, String ggCNatureOfContract, String ggCContractContact, String ggCTotalContractAmount, String ggCPaymentMethod, String ggCSignedBy, String ggCContractSeal, String ggCSignatureOfContract, String ggCRemarks, String ggCPploadInformation, String ggCExpirationReminder) throws Exception{
        return ggContractSerice.addContractItems(response, request, ggCNumber, ggCContractName, ggCInstitutionalName, ggCTypeOfContract, ggCcontractAmount,ggCpersonInCharge, ggCAuditStatus, ggCContractTime, ggCDueTime, ggCNatureOfContract, ggCContractContact, ggCTotalContractAmount, ggCPaymentMethod, ggCSignedBy, ggCContractSeal, ggCSignatureOfContract, ggCRemarks, ggCPploadInformation, ggCExpirationReminder);
    }

    /**
     * 删除全部
     */
    @PostMapping("/delectContract")
    public Object delectContract(HttpServletResponse response, HttpServletRequest request, String ggCNumber)throws  Exception{
        return ggContractSerice.delectContract(response, request, ggCNumber );
    }

    /**
     * 修改
     */
    @PostMapping("/updateContractItems")
    public Object updateContractItems(HttpServletResponse response, HttpServletRequest request, String ggCNumber, String ggCContractName, String ggCInstitutionalName, String ggCTypeOfContract, String ggCcontractAmount, String ggCpersonInCharge, String ggCAuditStatus, String ggCContractTime, String ggCDueTime, String ggCNatureOfContract, String ggCContractContact, String ggCTotalContractAmount, String ggCPaymentMethod, String ggCSignedBy, String ggCContractSeal, String ggCSignatureOfContract, String ggCRemarks, String ggCPploadInformation, String ggCExpirationReminder,Integer ggCId) throws Exception{
        return ggContractSerice.updateContractItems(response, request, ggCNumber, ggCContractName, ggCInstitutionalName, ggCTypeOfContract, ggCcontractAmount, ggCpersonInCharge, ggCAuditStatus, ggCContractTime, ggCDueTime, ggCNatureOfContract, ggCContractContact, ggCTotalContractAmount, ggCPaymentMethod, ggCSignedBy, ggCContractSeal, ggCSignatureOfContract, ggCRemarks, ggCPploadInformation, ggCExpirationReminder, ggCId);
    }

    /**
     * 查询
     */
    @PostMapping("/getContract")
    public Object getContract(HttpServletResponse response, HttpServletRequest request, Integer page, Integer pageNumber, @RequestParam(name = "name", required = false) String name, @RequestParam(name = "type", required = false) String type,@RequestParam(name = "starttime", required = false)  String starttime,@RequestParam(name = "endtime", required = false)  String endtime) throws Exception {
        return ggContractSerice.getContract(response, request, page, pageNumber, name, type, starttime, endtime);
    }

    /**
     * 单个查询
     */
    @PostMapping("/getContractItems")
    public Object getContractItems(HttpServletResponse response, HttpServletRequest request, Integer itemsid) throws Exception{
        return ggContractSerice.getContractItems(response, request, itemsid);
    }

    /**
     * 单个删除
     */
    @PostMapping("/delectContractItmes")
    public Object delectContractItmes(HttpServletResponse response, HttpServletRequest request, Integer itemsid) throws Exception{
        return ggContractSerice.delectContractItmes(response, request, itemsid);
    }

    /**
     * 文件上传
     */
    @RequestMapping("/uploadContract")
    public String  uploadContract(HttpServletResponse response, HttpServletRequest request,@RequestParam("file") MultipartFile file) throws Exception{
        return ggContractSerice.uploadContract(response, request, file);
    }

}
